/*
 * Copyright 2007 Ulf Ochsenfahrt <ulf@ofahrt.de>
 *
 * This file is part of mnemoj, a software transactional memory implementation
 * that is based on Project Darkstar.
 *
 * mnemoj is free software: you can redistribute it
 * and/or modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation and
 * distributed hereunder to you.
 *
 * Project Darkstar Server is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.ofahrt.mnemoj.impl;

import com.sun.sgs.app.Task;

import de.ofahrt.mnemoj.PersistenceManager;

public class AbstractPersistenceManager implements PersistenceManager
{

private final Storage storage;

public AbstractPersistenceManager(Storage storage)
{
	this.storage = storage;
}

@Override
public long getCurrentTime()
{ return storage.getCurrentTime(); }

@Override
public void advanceTime(long toTime)
{ storage.advanceTime(toTime); }

@Override
public void execute(Task task)
{
	Transaction transaction = new Transaction(storage, storage.getCurrentTime());
	ManagerContext context = new ManagerContext(transaction);
	AppContextDispatcher.call(context, task);
}

}
